<%@taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<%@taglib prefix="sj" tagdir="/WEB-INF/tags/spring-jquery-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<%
response.setHeader("Cache-Control","no-cache"); 
response.setHeader("Cache-Control", "no-cache"); //HTTP 1.1
response.setHeader("Cache-Control", "private"); // HTTP 1.1
response.setHeader("Cache-Control", "no-store"); // HTTP 1.1
response.setHeader("Cache-Control", "must-revalidate"); // HTTP 1.1
response.setHeader("Cache-Control", "max-stale=0"); // HTTP 1.1 
response.setHeader("Cache-Control", "post-check=0"); // HTTP 1.1 
response.setHeader("Cache-Control", "pre-check=0"); // HTTP 1.1 
response.setHeader("Pragma", "no-cache"); // HTTP 1.0 
response.setDateHeader ("Expires", -1);
%>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="-1">

<script>
	$(document).ready(function() {
		$("#loginForm").validate({
			rules : {
				loginName : {
					required : true
				},
				password : {
					required : true
				}
			}
		});
	});

	function loginFormSubmitComplete(responce) {
		if ($.trim(responce) == 'success') {
			top.location.href = 'secure/showDashboard.do';
		} else {
			$('#login-form').html(responce);
		}
	}
</script>
<script>
$.ajax({
cache: false,
dataType: "text",
  url: "secure/checkSession.do",
      success: function(data){
       // alert("loginform...."+$.trim(data));
       if ($.trim(data) == 'success') {
       top.location.href = 'secure/showDashboard.do';
    }
  }
});
// top.location.href = 'secure/showDashboard.do';
 //alert(response1);
</script>
<c:url value="/login.do" var="loginUrl" />
<form:form name="loginForm" id="loginForm" action="${loginUrl}" method="post" commandName="user">
	<table>
		<tr class="row">
			<td class="label">&nbsp;</td>
			<td class="input-field" colspan="2">LoginForm<form:errors path="" cssClass="error" element="div" /></td>
		</tr>
		<tr class="row">
			<td class="label"><spring:message code="login.label.username" /></td>
			<td class="input-field"><form:input path="loginName" cssClass="input-full-width" /></td>
			<td><form:errors path="loginName" cssClass="error" /></td>
		</tr>
		<tr class="row">
			<td class="label"><spring:message code="login.label.password" /></td>
			<td class="input-field"><form:password path="password" cssClass="input-full-width" /></td>
			<td><form:errors path="password" cssClass="error" /></td>
		</tr>
		<tr class="row">
			<td class="label">&nbsp;</td>
			<td class="input-field"><sj:submit id="loginFormSubmit" key="login.button.login" validate="true" submitComplete="loginFormSubmitComplete" /> <input type="reset" value="<spring:message code='login.button.reset' />" /></td>
			<td>&nbsp;</td>
		</tr>
	</table>
</form:form>
